<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增工单明细')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-detail-add">
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">工单主表id：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="workOrderId" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">工单号：</label>
                <div class="col-sm-8">
                    <input name="workOrder" id="workOrder" th:each="list:${workOrder}" class="form-control" type="text"  th:value="${list['workOrder']}" readonly>
                </div>
            </div>
            <div class="form-group" hidden="hidden">
                <label class="col-sm-3 control-label">工单号id：</label>
                <div class="col-sm-8">
                    <input name="workOrderId" id="workOrderId" th:each="list:${workOrder}" class="form-control" type="text"  th:value="${list['id']}" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">设备名称：</label>
                <div class="col-sm-8">
                    <select id="machineId" name="machineId" class="form-control">
                        <option th:each="list : ${machine}" th:text="${list['machineName']}" th:value="${list['machineId']}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">bom配方：</label>
                <div class="col-sm-8">
                    <select id="bomId" name="bomId" class="form-control">
                        <option th:each="list : ${bom}" th:text="${list['bomName']}" th:value="${list['bomId']}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">工序</label>
                <div class="col-sm-8">
                    <!--                    <input name="process" class="form-control" type="text">-->
                    <select name="process" id="process" class="form-control m-b" th:with="type=${@dict.getType('work_process')}" onclick="setProcessWorkOrder()">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">工序工单号：</label>
                <div class="col-sm-8">
                    <input name="processWorkOrder" id="processWorkOrder" class="form-control" type="text" readonly>
                </div>
            </div>

<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">状态</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <select name="status" class="form-control m-b" th:with="type=${@dict.getType('work_status')}">-->
<!--                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--                    </select>-->
<!--                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>-->
<!--                </div>-->
<!--            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "workorder/detail"
        $("#form-detail-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $("#form-detail-add").serializeArray();
                // var principalId = $("#principalName option:selected").val();
                // data.push({"name": "principalId", "value": principalId});

                $.operate.save(prefix + "/add", data);
            }
        };
        $(function () {
            var process = setProcessWorkOrder();
            var workorder = $('#workOrder').val();
            workorder = workorder + "-0" + process;
            $('#processWorkOrder').val(workorder);
        })
        function setProcessWorkOrder() {
            var process = $('#process option:selected').val();
            var workorder = $('#workOrder').val();
            workorder = workorder + "-0" + process;
            $('#processWorkOrder').val(workorder);
            return process;
        }
    </script>
</body>
</html>